package cn.edu.tju.core.utils;

public class HttpResult<T> {

    private Integer code;

    private String msg;

    private T data;

    public static <T> HttpResult<T> ok(T data) {
      HttpResult<T> r = new HttpResult<>();
        r.setCode(200);
        r.setMsg("success");
        r.setData(data);
        return r;
    }

    public static <T> HttpResult<T> ok() {
      HttpResult<T> r = new HttpResult<>();
        r.setCode(200);
        r.setMsg("success");
        return r;
    }

    public static <T> HttpResult<T> fail(String msg) {
      HttpResult<T> r = new HttpResult<>();
        r.setCode(400);
        r.setMsg(msg);
        return r;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}


